package com.huayun.code.gen;

import com.huayun.code.core.gen.AbstractGenerator;
import com.huayun.code.core.gen.AbstractTableGenerator;
import com.huayun.code.core.utils.ConfigUtils;
import com.huayun.code.core.utils.NameUtils;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
public class ApiExtGen extends AbstractTableGenerator {

    @Override
    protected Map<String, Object> getDataModel() {
        String basePackage = ConfigUtils.getBasePackage();
        Map<String, Object> data = super.getDataModel();
        data.put("requestMapping", NameUtils.getRequestMapping(table.getName()));

        data.put("moduleName", basePackage.substring(basePackage.lastIndexOf('.') + 1));
        data.put("classname", table.getCamelClazzName());
        return data;
    }

    @Override
    public String getFileName() {
        return table.getClazzName() + "ApiExt.java";
    }

    @Override
    public String getType() {
        return AbstractGenerator.CONTROLLER;
    }
}
